package com.tjtt.gwm.action;

import com.tjtt.tdm.base.BaseAction;
import java.io.File;
import java.util.Calendar;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import jxl.Sheet;
import jxl.Workbook;
import org.apache.struts2.ServletActionContext;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.sun.org.apache.bcel.internal.generic.NEW;
import com.tjtt.common.utils.ExcelExportUtil;
import com.tjtt.common.utils.TotalFlowXmlTool;
import com.tjtt.gwm.bean.*;
import com.tjtt.gwm.service.*;
import com.tjtt.tdm.base.PageResult;
import com.tjtt.tdm.base.PubMethod;
import com.tjtt.tdm.base.StringUtil;
import com.tjtt.tdm.flow.bean.FlowTask;
import com.tjtt.tdm.flow.bean.FlowTaskInfo;
import com.tjtt.tdm.flow.bean.Flowstate;
import com.tjtt.tdm.form.service.IAutoService;

import com.tjtt.tdm.codeReview.service.ICodeReviewService;
import com.tjtt.tdm.flow.bean.Flowtype;
import com.tjtt.tdm.flow.service.IFlowformService;
import com.tjtt.tdm.flow.service.IFlowtypeService;

public class EEPRelationsAction extends BaseAction {
	private EEPRelationsService eepRelationsService;
	
	private EEPRelations eepRelations;
	
	public EEPRelationsService getEepRelationsService() {
		return eepRelationsService;
	}
	public void setEepRelationsService(EEPRelationsService eepRelationsService) {
		this.eepRelationsService = eepRelationsService;
	}
	public EEPRelations getEepRelations() {
		return eepRelations;
	}
	public void setEepRelations(EEPRelations eepRelations) {
		this.eepRelations = eepRelations;
	}
	//---------------------查询当前选择的适用设备信息----------------------------
	public  void queryChooseEQU()throws Exception {
		try {
			String equIds = StringUtil.encodingUrl(getRequest().getParameter(
					"equIds"));
			Map<String, String> filterMap = getPagerMap();
			if (null != equIds && !"".equals(equIds)) {
				equIds = StringUtil.encodingUrl(equIds);
				filterMap.put("equIds", equIds);
			}
			PageResult result = eepRelationsService.queryChooseEQUByEquIds(filterMap);
			String[] viewArray = { "eId", "eName", "eNo" };
			String str = getColumnJson(result, viewArray);
			System.out.println("------------------" + str);
			HttpServletResponse response = ServletActionContext.getResponse();
			response.setContentType("application/XML,charset=GBK");
			response.setHeader("Charset", "GBK");
			response.setCharacterEncoding("GBK");
			response.setContentType("text/xml");
			PrintWriter out = getResponse().getWriter();
			out.print(str);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	//---------------------查询当前备件的适用设备信息----------------------------
		public void  queryReDataByEP()throws Exception {
			try {
				String epId = this.getRequest().getParameter("epId");
				Map<String, String> filterMap = getPagerMap();
				if (null != epId && !"".equals(epId)) {
					epId = StringUtil.encodingUrl(epId);
					filterMap.put("epId", epId);
				}
				PageResult result = eepRelationsService.queryReDataByEP(filterMap);
				String[] viewArray = { "eId", "eName", "eNo" };
				String str = getColumnJson(result, viewArray);
				System.out.println("------------------" + str);
				HttpServletResponse response = ServletActionContext.getResponse();
				response.setContentType("application/XML,charset=GBK");
				response.setHeader("Charset", "GBK");
				response.setCharacterEncoding("GBK");
				response.setContentType("text/xml");
				PrintWriter out = getResponse().getWriter();
				out.print(str);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
	
	
	

}
